home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
TPUG - Toronto PET Users Group
/
TPUG Users Group CD
/
TPUG Users Group CD.iso
/
CRS
/
crs54.d81
/
trans12c.lbr
/
TRANS-06.INC
< prev
next >
Wrap
Text File
|
2009-10-10
|
3KB
|
127 lines
procedure FormatMS_DOS;
{type
str40 = string[40];}
var
Ch: char;
I: integer;
FormatNumber: integer;
{function Yes(Message: str40): boolean;
begin
write(Message, 'Y or N? ');
readln(Ch);
if (upcase(Ch) = 'Y') then
Yes := true
else
Yes := false;
end;}
type
User0Command = record {8502 BIOS function 4, Subfunction 8: }
Command: byte; { Format a diskette }
Par4: byte;
Par5: byte;
Par6: byte;
Par7: byte;
Par8: byte;
Par9: byte;
Par10: byte;
Par11: byte;
end;
const
FormatCommand: array[0..3] of User0Command =
((Command:38; Par4:129; Par5:0; Par6:2; Par7:39; {MSDOS-1 DS}
Par8:8; Par9:0; Par10:0; Par11:0),
(Command:6; Par4:129; Par5:0; Par6:2; Par7:39; {MSDOS-1 SS}
Par8:8; Par9:0; Par10:0; Par11:0),
(Command:38; Par4:129; Par5:0; Par6:2; Par7:39; {MSDOS-2 DS}
Par8:9; Par9:0; Par10:0; Par11:0),
(Command:6; Par4:129; Par5:0; Par6:2; Par7:39; {MSDOS-2 SS}
Par8:9; Par9:0; Par10:0; Par11:0));
procedure LoadFormatCommand(EntryIndex: integer);
var
I: integer;
begin
mem[$FD02] := 1; {DRIVE#: device 8, drive 0}
mem[$FD08] := 1; {FAST set}
mem[$FE00] := 9; {@BUFFER: set to command length}
for I := 0 to 8 do
mem[$FE01 + I] := mem[addr(FormatCommand[EntryIndex]) + I];
end;
begin (* FormatMS_DOS *)
if (bdos(CURDSK) <> 0) then
begin
writeln('Formatting MS-DOS disks will be done in Drive A.');
writeln('Insert a scratch CP/M disk in Drive A first, just to log onto it');
writeln('before proceeding with a blank disk to be formatted.');
BiosSelect(0, First);
end;
writeln;
writeln('Enter the type of disk to be formatted:');
writeln;
writeln(' 1 : MSDOS-1 DS (8 sec/trk)');
writeln;
writeln(' 2 : MSDOS-1 SS (8 sec/trk)');
writeln;
writeln(' 3 : MSDOS-2 DS (9 sec/trk)');
writeln;
writeln(' 4 : MSDOS-2 SS (9 sec/trk)');
writeln;
writeln;
write('Which one (1 - 4)? ');
repeat
read(KBD, Ch);
until (Ch in ['1'..'4']);
writeln(Ch);
FormatNumber := ord(Ch) - 49;
FAT[1] := not FormatNumber; {Disk Type Byte}
Stop := false;
writeln;
writeln(' *** Insert a blank disk to be formatted in drive A now ***');
write('Type $ to begin formatting. ');
repeat
read(KBD, Ch);
until (Ch = '$');
writeln(Ch);
LoadFormatCommand(FormatNumber); {8502 BIOS User function 4, Subfunction 8:}
D := bios3(USERFUN, 4, 0, 0, 8); { format a disk }
Stop := (mem[$FD06] <> 0); {VICDATA: Disk error status}
if Stop then
writeln('Error Formatting')
else
begin
BiosSelect(0, First); {initiallize drive for disk write}
fillchar(Buffer, 512, 0);
Buffer[1] := chr(FAT[1]);
FirstFATSector := 1;
FATSize := (FormatNumber div 2) + 1;
WriteSector(FirstFATSector, 0, addr(Buffer));
WriteSector(FirstFATSector + FATSize, 0, addr(Buffer));
writeln;
if not BiosError then
writeln('Formatting complete');
end;
Continue;
bdos(RESETDSK);
{bdos(LOGDSK, CPM_Drive);}
end;